package com.che.software.testato.domain.entity;

import java.io.Serializable;

import com.che.software.testato.domain.enumeration.PointType;

/**
 * Class representing an element.
 * 
 * @author Clement HELIOU (clement.heliou@che-software.com).
 * @copyright Che Software.
 * @license GNU General Public License.
 * @see Serializable
 * @since July, 2011.
 * 
 *        This file is part of Testato.
 * 
 *        Testato is free software: you can redistribute it and/or modify it
 *        under the terms of the GNU General Public License as published by the
 *        Free Software Foundation, either version 3 of the License, or (at your
 *        option) any later version.
 * 
 *        Testato is distributed in the hope that it will be useful, but WITHOUT
 *        ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 *        FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
 *        for more details.
 * 
 *        You should have received a copy of the GNU General Public License
 *        along with Testato. If not, see <http://www.gnu.org/licenses/>.
 * 
 *        Testato's logo is a creation of Arrioch
 *        (http://arrioch.deviantart.com/) and it's distributed under the terms
 *        of the Creative Commons License.
 */
public class Element implements Serializable {

	/**
	 * Constants.
	 */
	private static final long serialVersionUID = -1151307192793033226L;

	/**
	 * Members.
	 */
	private int activityId, elementId, pointId, testCaseId;
	private PointType pointType;
	private String label, pointTypeString;

	/**
	 * Default builder.
	 */
	public Element() {
	}

	/**
	 * Builder from fields.
	 * 
	 * @param activityId the activity id.
	 * @param elementId the element id.
	 * @param pointId the point id.
	 * @param testCaseId the test case id.
	 * @param pointType the point type.
	 * @param label the label.
	 * @param pointTypeString the point type string.
	 */
	private Element(int activityId, int elementId, int pointId, int testCaseId, PointType pointType, String label, String pointTypeString) {
		super();
		this.activityId = activityId;
		this.elementId = elementId;
		this.pointId = pointId;
		this.testCaseId = testCaseId;
		this.pointType = pointType;
		this.label = label;
		this.pointTypeString = pointTypeString;
	}

	/**
	 * Builder as a clone factory.
	 * 
	 * @param toClone the object to clone.
	 */
	public Element(Element toClone) {
		this(toClone.activityId, toClone.elementId, toClone.pointId, toClone.testCaseId, toClone.pointType, toClone.label, toClone.pointTypeString);
	}

	/**
	 * Getter for the private field value activityId.
	 * 
	 * @return the activityId field value.
	 */
	public int getActivityId() {
		return activityId;
	}

	/**
	 * Setting a value to the activityId field.
	 * 
	 * @param activityId the value to set.
	 */
	public void setActivityId(int activityId) {
		this.activityId = activityId;
	}

	/**
	 * Getter for the private field value elementId.
	 * 
	 * @return the elementId field value.
	 */
	public int getElementId() {
		return elementId;
	}

	/**
	 * Setting a value to the elementId field.
	 * 
	 * @param elementId the value to set.
	 */
	public void setElementId(int elementId) {
		this.elementId = elementId;
	}

	/**
	 * Getter for the private field value pointId.
	 * 
	 * @return the pointId field value.
	 */
	public int getPointId() {
		return pointId;
	}

	/**
	 * Setting a value to the pointId field.
	 * 
	 * @param pointId the value to set.
	 */
	public void setPointId(int pointId) {
		this.pointId = pointId;
	}

	/**
	 * Getter for the private field value testCaseId.
	 * 
	 * @return the testCaseId field value.
	 */
	public int getTestCaseId() {
		return testCaseId;
	}

	/**
	 * Setting a value to the testCaseId field.
	 * 
	 * @param testCaseId the value to set.
	 */
	public void setTestCaseId(int testCaseId) {
		this.testCaseId = testCaseId;
	}

	/**
	 * Getter for the private field value label.
	 * 
	 * @return the label field value.
	 */
	public String getLabel() {
		return label;
	}

	/**
	 * Setting a value to the label field.
	 * 
	 * @param label the value to set.
	 */
	public void setLabel(String label) {
		this.label = label;
	}

	/**
	 * Getter for the private field value pointType.
	 * 
	 * @return the pointType field value.
	 */
	public PointType getPointType() {
		return (null != pointTypeString && !"".equalsIgnoreCase(pointTypeString)) ? PointType.valueOf(pointTypeString.toUpperCase()) : pointType;
	}

	/**
	 * Setting a value to the pointType field.
	 * 
	 * @param pointType the value to set.
	 */
	public void setPointType(PointType pointType) {
		this.pointType = pointType;
	}

	/**
	 * Getter for the private field value pointTypeString.
	 * 
	 * @return the pointTypeString field value.
	 */
	public String getPointTypeString() {
		return pointTypeString;
	}

	/**
	 * Setting a value to the pointTypeString field.
	 * 
	 * @param pointTypeString the value to set.
	 */
	public void setPointTypeString(String pointTypeString) {
		this.pointTypeString = pointTypeString;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return label;
	}
}